<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
<html>
<head>
<script type="text/javascript">
	$(function() {
		$('input').checkBox();
		$('#toggle-all').click(function() {
			$('#toggle-all').toggleClass('toggle-checked');
			$('#mainform input[type=checkbox]').checkBox('toggle');
			return false;
		});
	});
</script>

<!--  styled select box script version 2 -->

<script type="text/javascript">
	$(document).ready(function() {
		$('.styledselect_form_1').selectbox({
			inputClass : "styledselect_form_1"
		});
		$('.styledselect_form_2').selectbox({
			inputClass : "styledselect_form_2"
		});
	});
</script>

<!--  styled file upload script -->

<script type="text/javascript" charset="utf-8">
	$(function() {
		$("input.file_1").filestyle({
			image : "<spring:theme code='theme.admin'/>/imageForms/upload_file.gif",
			imageheight : 29,
			imagewidth : 78,
			width : 300
		});
	});
</script>
<!--  date picker script -->
<script type="text/javascript" charset="utf-8">
	$(function() {
		// initialise the "Select date" link
		$("#seDate")
				.datepicker(
						// associate the link with a date picker
						{
							showOn : 'button',
							buttonImage : '<spring:theme code="theme.admin.images"/>/calendar.gif',
							buttonImageOnly : true,
							changeMonth : true, // must be disabled when using maxDate
							changeYear : true,
						//onSelect:function(selectedDate){
						//alert("as");
						//your_function(selectedDate);
						//}
						});
		$("#datepicker").datepicker();
	});
</script>
<!--end form -->
<title>Thông tin sách</title>
</head>
<body>
	<div id="page-heading">
		<h1>Thêm Sách</h1>
	</div>
	<form:form action="save-book" commandName="bookVO" method="post" enctype="multipart/form-data">
		<!-- start id-form -->
		<form:hidden path="id"/>
		<form:hidden path="publisherId"/>
		<form:hidden path="likeNumber"/>
		<form:hidden path="createDate"/>
		<form:hidden path="status"/>
		<form:hidden path="urlImageFile"/>
		<form:hidden path="urlPdfFile"/>
		
		<table border="0" cellpadding="0" cellspacing="0" id="id-form">
			<tr>
				<th valign="top">Tên sách:</th>
				<td><form:input path="name" class="inp-form" /></td>
				<td><form:errors path="name" class="error" /></td>
			</tr>
			
			<tr>
				<th valign="top">Tiêu đề sách:</th>
				<td><form:input path="title" class="inp-form" /></td>
				<td><form:errors path="title" class="error" /></td>
			</tr>
			
			<tr>
				<th valign="top">Tái bản lần:</th>
				<%-- <td><form:input path="numberRepublish" class="inp-form" /></td> --%>
				<td>
					<form:select path="numberRepublish" class="styledselect_form_1">
						<c:forEach begin="0" end="50" step="1" var="number">
							<c:if test="${number == numberRepublishChoose}">
								<option value="${number}" selected="selected">${number} </option>
							</c:if>
							<c:if test="${number != numberRepublishChoose}">
								<option value="${number}">${number} </option>
							</c:if>
						</c:forEach>
					</form:select>
				</td>
				<td><form:errors path="numberRepublish" class="error" /></td>
			</tr>
			
			<tr>
				<th valign="top">Ngày xuất bản:</th>
				<td class="noheight">
	
					<table border="0" cellpadding="0" cellspacing="0">
						<tr valign="top">
							<td>
							<td><form:input path="datePublish" class="inp-form" id="seDate" /></td>
						</tr>
					</table>
				</td>
				<td><form:errors path="datePublish" class="error" /></td>
			</tr>
			
			<tr>
				<th valign="top">Loại sách:</th>
				<td><form:select path="bookTypeId" class="styledselect_form_1">
						<!-- <option value="">All</option>
						<option value="">Products</option>
						<option value="">Categories</option>
						<option value="">Clients</option>
						<option value="">News</option> -->
						<option value="0">Loại sách</option>
						<c:forEach items="${bookTypeList }" var="bookType" >
							<c:if test="${bookType.id == bookTypeChoose}">
								<option value="${bookType.id}" selected="selected">${bookType.name} </option>
							</c:if>
							
							<c:if test="${bookType.id != bookTypeChoose}">
								<option value="${bookType.id}">${bookType.name} </option>
							</c:if>
						</c:forEach>
				</form:select></td>
				<td><form:errors path="bookTypeId" class="error" /></td>
			</tr>
			
			<tr>
				<th valign="top">Tác giả:</th>
				<td><form:input path="author" class="inp-form" /></td>
				<td><form:errors path="author" class="error" /></td>
			</tr>
			
			<tr>
				<th valign="top">Giá:</th>
				<td><form:input path="price" class="inp-form" /></td>
				<td><form:errors path="price" class="error" /></td>
			</tr>
			
			<tr>
				<th valign="top">Giảm giá:</th>
				<td><form:input path="discount" class="inp-form" /> %</td>
				<td><form:errors path="discount" class="error" /></td>
			</tr>
			
			<tr>
				<th valign="top">Mô tả tóm tắt:</th>
				<td><form:textarea path="shortDescription" rows="" cols="" class="form-textarea"></form:textarea></td>
				<td><form:errors path="shortDescription" class="error" /></td>
			</tr>
	
			<tr>
				<th valign="top">Mô tả chi tiết:</th>
				<td><form:textarea path="longDescription" rows="" cols="" class="form-textarea"></form:textarea></td>
				<td><form:errors path="longDescription" class="error" /></td>
			</tr>
	
			<!-- <tr>
				<th valign="top">Ngày thêm:</th>
				<td class="noheight">
	
					<table border="0" cellpadding="0" cellspacing="0">
						<tr valign="top">
							<td>
							<td><input type="text" class="inp-form" id="seDate" /></td>
						</tr>
					</table>
	
				</td>
				<td></td>
			</tr> -->
	
			<!-- <tr>
				<th valign="top">Tên nhà sản xuất:</th>
				<td><select class="styledselect_form_1">
						<option value="">All</option>
						<option value="">Products</option>
						<option value="">Categories</option>
						<option value="">Clients</option>
						<option value="">News</option>
				</select></td>
				<td></td>
			</tr> -->
	
	
			<tr>
				<th valign="top">Trạng thái:</th>
				<td>
				<form:radiobutton path="active" value="1" class=".inp-form-radio" /><label>Hiển thị</label> 
				<form:radiobutton path="active" value="0" class=".inp-form-radio" /><label>Không hiển thị</label>
				<%-- <form:select path="active" class="styledselect_form_1">
						<option value="0">Không hiển thị</option>
						<option value="1">Hiển thị</option>
				</form:select> --%>
				</td>
				<td><form:errors path="active" class="error" /></td>
			</tr>
			
			<tr>
				<th valign="top">Sản phẩm hot:</th>
				<td><form:checkbox path="isHot" value="true" class="form-checkbox"/></td>
				<td><form:errors path="isHot" class="error" /></td>
			</tr>
			
			<tr>
				<th>Ảnh hiện tại:</th>
				<td>${imageCurrent }</td>
				<td>
				</td>
			</tr>
			
			<tr>
				<th>Upload ảnh:</th>
				<td><form:input type="file" path="imageFileUpload" class="file_1" /></td>
				<td>
					<div class="bubble-left"></div>
					<div class="bubble-inner">JPG,PNG,JPEG,GIF. Tối đa là 2MB</div>
					<div class="bubble-right"></div>
				</td>
			</tr>
			<c:if test="${hasErrorUploadImage }">
				<tr>
					<th></th>
					<td><span class="error">${errorUploadImage }</span></td>
				</tr>
			</c:if>
				<tr>
					<th>File PDF:</th>
					<td>${pdfCurrent }</td>
					<td>
					</td>
				</tr>
			
			<tr>
				<th>Upload file:</th>
				<td><form:input type="file" path="pdfFileUpload" class="file_1" /></td>
				<td>
					<div class="bubble-left"></div>
					<div class="bubble-inner">PDF, ePub file </div>
					<div class="bubble-right"></div>
				</td>
				
			</tr>
			<c:if test="${hasErrorUploadPdf }">
				<tr>
					<th></th>
					<td><span class="error">${errorUploadPdf }</span></td>
				</tr>
			</c:if>
			<tr>
				<th>&nbsp;</th>
				<td valign="top"><input type="submit" value="Lưu" class="form-submit" />
					<input type="reset" value="Hủy" class="form-reset" onclick="window.location.href='book-info'"/></td>
				<td></td>
			</tr>
		</table>
	</form:form>
</body>
</html>